<?php
/**
 * The Template for displaying product archives, including the main shop page which is a post type archive.
 *
 * Override this template by copying it to yourtheme/woocommerce/archive-product.php
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */
if (!defined('ABSPATH'))
    exit; // Exit if accessed directly

get_header('shop');
?>
<script type="text/javascript">
    $('.header').addClass('product shop-online');
</script>
<div class="row">
    <div class="col-lg-4 col-sm-4 col-12 header-description align-right">
        <div class="title step">
            <h2 class="line_1"><?php woocommerce_page_title(); ?></h2>

        </div>
    </div>
</div>
</div>
</div>
<div class="main-content container">
    <div class="row">
        <?php
        wp_reset_query();
        global $wp_query, $product;
       
        $args = array_merge($wp_query->query_vars, array('posts_per_page' => '24', 'orderby' => 'ID', 'order' => 'DESC'));
        query_posts($args);

        if (have_posts()) :
            $i = 0;
            while (have_posts()) : the_post();

               
                    echo!$i || !($i % 6) ? '<div class="row">' : '';
                    woocommerce_get_template_part('content', 'product_tag');
                    echo!(($i + 1) % 6) ? '</div>' : '';
                    $i++;
                endwhile; // end of the loop.  
                 echo (($i) % 6) ? '</div>' : '';
                ?>
                <!-- pagination --> 
                <div class="paginations">
                    <?php do_action('woocommerce_pagination') //echo woo_pagination($args);   ?>
                </div>
            </div>
        <?php elseif (!woocommerce_product_subcategories(array('before' => woocommerce_product_loop_start(false), 'after' => woocommerce_product_loop_end(false)))) : ?>

            <?php woocommerce_get_template('loop/no-products-found.php'); ?>

        <?php endif; ?>



    </div>
</div>
<!-- Content -->
<div class="container">
    <div class="row">
        <?php
        wp_reset_query();
        global $wp_query, $product;
        $curr_query = $wp_query->query_vars;
        ;
        $args = array_merge($wp_query->query_vars, array('posts_per_page' => '6', 'paged' => $curr_query['page'], 'orderby' => 'post_title', 'order' => 'DESC'));
        query_posts($args);

        if (have_posts()) :
            ?>
            <div class=" col-12 m10 list-product visible-md">
                <?php
                $i = 0;
                while (have_posts()) : the_post();
                    ?>


                    <?php
                    echo!$i || !($i % 3) ? '<div class="row">' : '';
                    woocommerce_get_template_part('content', 'product');
                    echo!(($i + 1) % 3) ? '</div>' : '';
                    $i++;
                endwhile; // end of the loop.  
                 echo (($i ) % 3) ? '</div>' : '';
                ?>
                <!-- pagination --> 
                <div class="paginations">
                    <?php do_action('woocommerce_pagination') //echo woo_pagination($args);    ?>
                </div>
            </div>
        <?php elseif (!woocommerce_product_subcategories(array('before' => woocommerce_product_loop_start(false), 'after' => woocommerce_product_loop_end(false)))) : ?>

            <?php woocommerce_get_template('loop/no-products-found.php'); ?>

        <?php endif; ?>
    </div>
    <div class="row">
        <?php
        wp_reset_query();
        $posts_per_page = 6;
        query_posts(array('posts_per_page' => $posts_per_page));
        if (have_posts())
            while (have_posts()): the_post();
                if (has_post_thumbnail()) {
                    $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                    $url_to_image = $large_image_url[0];
                } else {
                    $url_to_image = bloginfo('template_url') . '/img/no-image-blog-one.png';
                }
                ?>
                <div class="col-lg-4 col-sm-6 col-12">
                    <div class="news-item">
                        <div class="news-thumb">
                            <img src="<?php echo $url_to_image ?>" />
                        </div>
                        <div class="news-title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></div>
                        <div class="news-description">
                            <?php the_excerpt(''); ?> 
                        </div>
                        <div class="read-more">
                            <a href="<?php the_permalink() ?>">&raquo; Chi tiết</a>
                        </div>

                    </div>
                </div>
            <?php endwhile; ?>

    </div>
</div>
<?php get_footer('shop'); ?>